package com.andy.web.file.controller;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.andy.domain.result.BaseResult;
import com.andy.web.file.service.FileService;

@RestController
@RequestMapping("/file")
public class AndyFileController {
	
	@Autowired
	private FileService fileService;
	
	@RequestMapping("/upload")
	public BaseResult upload(@RequestParam("file") CommonsMultipartFile file, HttpServletRequest request,
			HttpServletResponse response) throws UnsupportedEncodingException {
		return fileService.upload2PythonServer(file, request, response);
	}
}
